//
//  MovieCellCollectionViewCell.m
//  MyMovie
//
//  Created by apple on 16/5/17.
//  Copyright © 2016年 ljp. All rights reserved.
//

#import "MovieCellCollectionViewCell.h"

@implementation MovieCellCollectionViewCell

- (void)awakeFromNib {
    // Initialization code
}
//重写设置器方法,给imageView设置图片
-(void)setMovie:(Movie *)movie {

    if (_movie == movie) {
        return;
    }

    _movie = movie;
    NSURL *url = [NSURL URLWithString:movie.images[@"large"]];
    [_moviePostCellImageView sd_setImageWithURL:url];

    _titleLable.text = [NSString stringWithFormat:@"中文名:%@", movie.title];
    _original_titleLable.text = [NSString stringWithFormat:@"英文名:%@", movie.original_title];
    _yearLable.text = [NSString stringWithFormat:@"年份:%@", movie.year];
    _ratingLable.text = [NSString stringWithFormat:@"%.1f", movie.rating];
    [_ratingView changeRating:movie.rating];
    [_detailImageview sd_setImageWithURL:url];


}
- (void)flipCell {

    [UIView transitionWithView:self
                      duration:0.4
                       options:UIViewAnimationOptionTransitionFlipFromLeft
                    animations:^{
                        [self.contentView exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
                    }
                    completion:nil];

}

- (void)restore {

    NSArray *subViewsArray = self.contentView.subviews;
    if ([[subViewsArray firstObject] isKindOfClass:[UIImageView class]]) {
        [self.contentView exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
    }
}

@end
